package com.jy.oss.controller;

import com.jy.commonutils.R;
import com.jy.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author GrainProjectTeam
 * @create 2020 - 12 - 10  22:25
 * MultipartFile: 用于获取上传的文件
 * url: OSS的路径
 */
@RestController
@RequestMapping("/eduoss/fileoss/")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    @PostMapping // 上传头像方法
    public R uploadOssFile(MultipartFile file) {
        String url = ossService.uploadOssFileAvatar(file);
        return R.ok().data("url", url);
    }

}
